﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EPiServer.Core;

namespace EPiServer.Models
{
    public interface IEPiServerPageModel
    {
        string PageName { get; set; }
        DateTime Created { get; set; }
        DateTime Changed { get; set; }
        string LanguageBranch { get; set; }
        PageReference PageLink { get; set; }
        string LinkURL { get; set; }
    }

    public class BaseModel : IEPiServerPageModel
    {
        //MainMenuContainer

        public string PageName { get; set; }
        public string MetaAuthor { get; set; }
        public string MetaDescription { get; set; }
        public string MetaKeywords { get; set; }
        public string MainIntro { get; set; }
        public DateTime Created { get; set; }
        public DateTime Changed { get; set; }
        public DateTime PageStartPublish { get; set; }
        public string LanguageBranch { get; set; }
        public string LinkURL { get; set; }
        public PageReference PageLink { get; set; }
        public string PageType { get; set; }

        public string BreadCrumb { get { return "<a href=/>Start</a> / <a href=/>TODO</a>"; } } //TODO: bygg upp breadcrumb

        public virtual StartPage Start { get; set; }
        public PageReference LoginPage { get; set; }


        public List<MenuLink> Menu { get; set; }
        public List<MenuLink> SubMenu { get; set; }

        //Ej metadata men används från masterpagen
        public virtual string Heading { 
            get {
                return PageName;
            } 
        }

        
        public PageReference RssContainer { get; set;}
        
        [PopulateFrom("RssContainer")]
        public List<Link> RssList { get; set;}
        public List<MetaTag> MetaList { get; set;}
        public List<Link> Languages { get; set; }

        public virtual string MainBody { get; set; }
        public virtual string SecondaryBody { get; set; }

        public string PageTitle
        {
            get
            {
                return string.Format("{0}{1}{2}", PageName, " - ", Configuration.Settings.Instance.SiteDisplayName);
            }
        }

        public BaseModel()
        {
            //RssContainer = PageReference.EmptyReference;
            MetaList = new List<MetaTag>();
            Menu = new List<MenuLink>();
            SubMenu = new List<MenuLink>();
            Languages = new List<Link>();
        }
    }
}